#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    setFixedSize(8*64,8*64);
    pBox=new Boxgame;
    pMap=new QPainter(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::keyPressEvent(QKeyEvent *event)
{
      pBox->keydown(event);
      if(pBox->gameover())
      {
          this->close();
      }
}

void Widget::paintEvent(QPaintEvent *event)
{
     Q_UNUSED(event);
    pMap->begin(this);
    pBox->drawmap(pMap);
    pMap->end();
    update();
}

